/* CoralCube | Massively Multiplayer Online Role-Playing Game(MMORPG) Emulator.
|* 
|* Copyright (C) 2008-2010 CoralCube <http://www.CoralCube.com/>
|*
|* This program is free software. You can redistribute it and/or modify it under the terms of 
|* the GNU General Public License as published by the Free Software Foundation, either 
|* version 2 of the License.
|*
|* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, 
|* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
|* See the GNU General Public License for more details.
|*
|* You should have received a copy of the GNU General Public License along with this program. 
|* If not, see <http://www.gnu.org/licenses/>.
|*/

#include "Check.h"

Check::Check() { }
Check::~Check() { }

void Check::CheckConfigVersion(uint32 const currVersion, uint32 const reqVersion)
{
    if (currVersion < reqVersion)
    {
        sLog.outError("*****************************************************************************");
        sLog.outError(" WARNING: Your settings.conf version indicates your conf file is out of date!");
        sLog.outError("          Please check for updates, as your current default values may cause");
        sLog.outError("          strange behavior.");
        sLog.outError("*****************************************************************************");
    }
}

void Check::CheckDatabaseVersion(uint32 db_type)
{
    switch (db_type)
    {
    case 1:
        if (!LoginDatabase.CheckVersionField("authserver_version", REVISION_DB_AUTH))
            exit(1);        
        break;
    case 2:
        if (!ConfigDatabase.CheckVersionField("config_version", REVISION_DB_CONFIG))
            exit(1);
        break;
    case 3:
        if (!CharacterDatabase.CheckVersionField("character_version", REVISION_DB_CHARACTERS))
            exit(1);
        break;
    case 4:
        if (!WorldDatabase.CheckVersionField("version", REVISION_DB_WORLD))
            exit(1);
        break;
    }
}